#include "head.h"

int elf_hash(char *key) // 对每个输入的命令返回对应的哈希值00000000
{
	int h = 0, g, i = 0;
	while (*key)
	{
		h = (h << 4) + *key++;
		g = h & 0xf0000000;
		if (g)
			h ^= g >> 24;
		h &= ~g;
	}
	return h % MAXKEY;
}

int init_hash(pCmdWord cmdword, int cmdword_length)
{ // 初始化存储命令的哈希表
	for (int i = 0; i < cmdword_length; ++i)
	{
		HashTable[elf_hash(cmdword[i].str)] = &cmdword[i];
	}
}